#include <jni.h>
#include <string>
#include "unistd.h"
#include "fmod.hpp" //方式实现和声明功能
//命名空间
using namespace FMOD;

#define VOICE_NORMAL 0
#define VOICE_LUOLI 1
#define VOICE_DASHU 2
#define VOICE_JINGSONG 3
#define VOICE_GAOGUAI 4
#define VOICE_KONGLING 5

extern "C"
JNIEXPORT void JNICALL
Java_com_beanbean_voicechanger_MainActivity_changeVoice(JNIEnv *env, jobject thiz, jstring path_,
                                                        jint voice_mode) {
    //把java String转成c/c++字符串
    const char *path = env->GetStringUTFChars(path_, NULL);
    /*System *system;
    Sound *sound;
    Channel *channel;
    //创建音频系统
    System_Create(&system);
    //初始化音频系统（最大音轨32，FMOD_INITFLAGS，额外驱动为null）
    system->init(32, FMOD_INIT_NORMAL, NULL);
    //创建声音
    system->createSound(path, FMOD_DEFAULT, NULL, &sound);

    switch (voice_mode) {
        case VOICE_NORMAL:
            system->playSound(sound, NULL, false, &channel);
            break;
        case VOICE_LUOLI:
            break;
        case VOICE_DASHU:
            break;
        case VOICE_JINGSONG:
            break;
        case VOICE_GAOGUAI:
            break;
        case VOICE_KONGLING:
            break;
        default:
            break;
    }

    system->update();
    unsigned int length = 0;
    //得到声音长度
    sound->getLength(&length, FMOD_TIMEUNIT_MS);
    //线程休眠（子线程还未完成播放，主线程已结束）
    usleep(length * 1000);
    //释放内存
    sound->release();
    system->release();*/
    env->ReleaseStringUTFChars(path_, path);
}